<template>
    <h2>添加客户信息</h2>

    <el-form :model="custForm" label-width="auto" style="max-width: 600px">
        <el-form-item label="客户姓名">
            <el-input v-model="custForm.name" />
        </el-form-item>
        <el-form-item label="地址">
            <el-input v-model="custForm.address" />
        </el-form-item>
        <el-form-item label="手机号">
            <el-input v-model="custForm.phone" />
        </el-form-item>
        <el-form-item label="客户类型">
            <el-select v-model="custForm.custType" placeholder="请选择客户类型">
                <el-option label="职业1" value="zhiye1" />
                <el-option label="职业2" value="zhiye2" />
            </el-select>
        </el-form-item>
        <el-form-item label="客户等级">
            <el-input v-model.number="custForm.level" type="text" autocomplete="off" />
        </el-form-item>

        <el-form-item label="历史总计">
            <el-input v-model="custForm.history" />
        </el-form-item>

        <el-form-item>
            <el-button type="primary" @click="onSubmit">创建</el-button>
            <el-button>取消</el-button>
        </el-form-item>
    </el-form>
</template>

<script setup>
import { reactive } from 'vue'
import axios from 'axios'
import { ElMessage } from 'element-plus'

const custForm = reactive({
    custName: '',
    address: '',
    phone: '',
    custType: '',
    level: 1,
    history: 0,

})

const onSubmit = () => {
    console.log(custForm)
    axios.post("http://localhost:8081/addCust", custForm).then((resp) => {
        console.log(resp.data)
        ElMessage({
            message: '提交成功!',
            type: 'success',
        })
    }).catch((error) => {
        console.log(error)
    })
}
</script>

<style scoped></style>